package cn.bevisoft.casex.dal.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.bevisoft.casex.dal.dao.UserDAO;
import cn.bevisoft.casex.dal.model.User;

@Repository("userDAO")
public class UserDAOImpl extends DAOImpl implements UserDAO {

	protected UserDAOImpl() {
		super("UserMapper");
	}

	@Override
	public int insertUser(User user) {
		return this.getSqlSession().insert(this.buildSqlId("insertUser"), user);
	}

	@Override
	public User selectUserByLoginIdAndPassword(String loginId, String password) {
		Map<String,String> parameterMap = new HashMap<String,String>();
		parameterMap.put("loginId", loginId);
		parameterMap.put("password", password);
		
		return this.getSqlSession().selectOne(this.buildSqlId("selectUserByLoginIdAndPassword"), parameterMap);
	}

	@Override
	public User selectUserByLoginId(String loginId) {
		return this.getSqlSession().selectOne(this.buildSqlId("selectUserByLoginId"), loginId);
	}
}
